package file.test;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class FileLineCheck {

    static List<String> BSList = new ArrayList<String>();
    static List<String> TAList = new ArrayList<String>();

    public static void main(String[] args) {
        readFileLineList();
        Map<Integer, String> map = getDeffrent();
        System.out.println(map.size());
    }

    public static void readFileLineList() {
        FileInputStream fis = null;
        InputStreamReader isr = null;
        BufferedReader br = null;
        String str = null;
        try {
            // C:\\Users\\Administrator\\Desktop\\预校验版本\\天安财产保险股份有限公司-000022-1-20170630.xml
            fis = new FileInputStream("C:\\Users\\Administrator\\Desktop\\预校验版本\\A.txt");
            isr = new InputStreamReader(fis);
            br = new BufferedReader(isr);

            int i = 0;
            while ((str = br.readLine()) != null) {
                BSList.add(str.trim());
				 /* if("<xbrli:identifierscheme=\"http://www.circ.gov.cn/\">000000</xbrli:identifier>".equals(str.replace(" ",""))){
					  System.out.println(i);
				  }
				  i++;*/
            }

            str = null;
            //C:\\Users\\Administrator\\Desktop\\预校验版本\\天安财产保险股份有限公司-000028-1-20170630_ta.xml
            fis = new FileInputStream("C:\\Users\\Administrator\\Desktop\\预校验版本\\B.txt");
            isr = new InputStreamReader(fis);
            br = new BufferedReader(isr);

            while ((str = br.readLine()) != null) {

                TAList.add(str.trim());

            }

        } catch (Exception e) {

        }
    }


    public static Map<Integer, String> getDeffrent() {
        Map<Integer, String> map1 = new HashMap<Integer, String>();
        Map<Integer, String> map2 = new HashMap<Integer, String>();

        String line = null;

        for (int i = 0; i < BSList.size(); i++) {
            line = BSList.get(i);
            if (!TAList.contains(line)) {
                map1.put(i, line);
                System.out.println("{" + i + "}" + line);
            }
        }
        System.out.println("==================================");
        for (int i = 0; i < TAList.size(); i++) {
            line = TAList.get(i);
            if (!BSList.contains(line)) {
                map2.put(i, line);
                System.out.println("{" + i + "}" + line);
            }
        }

        return map1;
    }

}
